#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        vector<int> res;
        sort(nums.begin(), nums.end());
        size_t i = 0;
        for (; i < nums.size() - 1;)
        {
            if (nums[i] == nums[i + 1])
            {
                i += 2;
            }
            else
            {
                res.push_back(nums[i]);
                i += 1;
            }
        }
        if (i < nums.size())
        {
            res.push_back(nums[i]);
        }

        return res;
    }
};